#include "ParticleSimple.h"

#include "ParticleContext.h"
#include "DescriptorParticle.h"

using namespace ParticleEngine; 

const DescriptorParticle ParticleSimple::Descriptor
(
	"Simple",
	[](ParticleContext& NewContext) { return new ParticleSimple(NewContext); }
);


ParticleSimple::ParticleSimple(ParticleContext& NewContext) :
ParticleBase(NewContext, &ParticleSimple::Descriptor),
	Heat(1.f)
{
	this->BrownMotion = 0.2f;
	this->Age = 0;
}
ParticleSimple::~ParticleSimple(void)
{
}

void ParticleSimple::Sole()
{
	this->SoleStandard();

	this->Age ++;
	if (this->Age == 1000)
		this->Context.ToRemoveArray.Add(this);
	this->Heat.Volume = 1.0f;

	this->Heat.Sole();
}

void ParticleSimple::InteractionIndividual(ParticleBase*const Other, Vec<2, float>& Space, const float& DistanceSquared)
{
	this->InteractionKinetics(Other, Space, DistanceSquared);

	this->Heat.Interaction(Other->HasHeat());
}
ColorRGBA<unsigned char> ParticleSimple::GetColor()
{
	return ColorRGBA<unsigned char> (255, 255 - (int)(Age * 0.001f * 255), 0, 255);
}

void ParticleSimple::SaveIndividual(std::ofstream& Strm)
{
	Heat.Save(Strm);
}
void ParticleSimple::LoadIndividual(std::ifstream& Strm)
{
	Heat.Load(Strm);
}


